package org.web.clientlistmanager.sdk.dto;

import org.web.base.domain.helper.ValidationHelper;

public class ClmHelper {

    public static String truncateString(String input, int maxLength) {
        if (input == null) {
            return null;
        }
        return input.length() <= maxLength ? input : input.substring(0, maxLength);
    }

    public static void validateLocalClientProcessDTO(LocalClientProcessDTO localClientProcessDTO) {
        ValidationHelper.validateAndThrow(LocalClientProcessDTO.class, localClientProcessDTO);
        if (localClientProcessDTO.getLocalClientTypeDetailDTOList() != null && localClientProcessDTO.getLocalClientTypeDetailDTOList().size() > 0) {
            for (LocalClientTypeListDTO localClientTypeListDTO : localClientProcessDTO.getLocalClientTypeDetailDTOList()) {
                ValidationHelper.validateAndThrow(LocalClientTypeListDTO.class, localClientTypeListDTO);
            }
        }
    }

}
